﻿using System.Collections.Generic;
using Web.UI.AdminLTE.Common;
using Web.UI.AdminLTE.Enums;
using Web.UI.TypeExtensions;

namespace Web.UI.AdminLTE.Controls.Simple
{
    public class Callout : HtmlElementBase
    {
        private string _message;
        private string _title;

        public Callout(CalloutType calloutType)
        {
            EnsureClass("callout", calloutType.GetEnumDescription());
        }

        public Callout Message(string message)
        {
            _message = message;
            return this;
        }

        public Callout Title(string title)
        {
            _title = title;
            return this;
        }

        public override string ToHtmlString()
        {
            return TagBuilderExtensions.New("div")
                 .MergeHtmlAttributes(HtmlAttr.FormatHtmlAttributes())
                 .Html(string.Format("<h4>{0}</h4>", _title))
                 .AppendHtml(string.Format("<p>{0}</p>", _message)).ToString();
        }

        //  Common methods for all html elements
        #region Common Methods
        public Callout HtmlAttributes(IDictionary<string, object> htmlAttributes)
        {
            MergeHtmlAttributes(htmlAttributes);
            return this;
        }

        public Callout HtmlAttributes(object htmlAttributes)
        {
            MergeHtmlAttributes(htmlAttributes);
            return this;
        }

        public Callout Id(string id)
        {
            SetId(id);
            return this;
        }

        public Callout Class(string cssClass)
        {
            EnsureClass(cssClass);
            return this;
        }

        public Callout Data(object htmlDataAttributes)
        {
            MergeHtmlDataAttributes(htmlDataAttributes);
            return this;
        }

        #endregion
    }
}